<?php

declare(strict_types=1);

namespace app\admin\controller;

use think\facade\Db;
use think\facade\Request;

class Admin
{
    public function index()
    {
        return '您好！这是一个[admin]示例应用';
    }

    public function test()
    {
        // var_dump(123);
        // $password = encrypt('123456');
        // var_dump($password);
        // $token = encrypt(time() . rand(999, 99999));
        // var_dump($token);
    }


    public function login()
    {
        $user = Request::param();
        $user['password'] = encrypt($user['password']);
        $tmp = Db::name('admin_user')->where($user)->find();

        if (!$tmp) {
            return jsonData(0, '账号密码不正确');
        }
        return jsonData(1, '登录成功', array("token" =>  $tmp['token']));
    }
}
